package com.office.web.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.office.common.core.domain.AjaxResult;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.office.system.service.MeetingMinutesService;

@RestController
@RequestMapping("/api/meeting/minutes")
public class MeetingMinutesController {

    // 假设有MeetingMinutesService用于处理业务逻辑
    @Autowired(required = false)
    private MeetingMinutesService meetingMinutesService;

    /**
     * 保存会议纪要
     */
    @PostMapping("/save")
    public AjaxResult saveMinutes(@RequestBody Map<String, Object> params) {
        // 这里应调用service保存纪要
        boolean success = true;
        if (meetingMinutesService != null) {
            success = meetingMinutesService.saveMinutes(params);
        }
        return success ? AjaxResult.success("纪要保存成功") : AjaxResult.error("纪要保存失败");
    }

    /**
     * 分发会议纪要
     */
    @PostMapping("/share")
    public AjaxResult shareMinutes(@RequestBody Map<String, Object> params) {
        // 这里应调用service分发纪要
        boolean success = true;
        if (meetingMinutesService != null) {
            success = meetingMinutesService.shareMinutes(params);
        }
        return success ? AjaxResult.success("纪要已分发给参会人") : AjaxResult.error("纪要分发失败");
    }

    /**
     * 查询会议纪要列表
     */
    @GetMapping("/list")
    public AjaxResult listMinutes(@RequestParam Map<String, Object> params) {
        List<Map<String, Object>> list = meetingMinutesService != null ? meetingMinutesService.listMinutes(params) : new java.util.ArrayList<>();
        return AjaxResult.success(list);
    }

    /**
     * 查询单个会议纪要详情
     */
    @GetMapping("/detail/{id}")
    public AjaxResult getMinutesDetail(@PathVariable("id") Long id) {
        Map<String, Object> detail = meetingMinutesService != null ? meetingMinutesService.getMinutesDetail(id) : new HashMap<>();
        return AjaxResult.success(detail);
    }
} 